<template>
  <footer>
    <router-link active-class="active" :to="{name: 'm-home'}">
      <i></i>
      <span>首页</span>
    </router-link>
    <router-link active-class="active" :to="{name: 'm-type'}">
      <i></i>
      <span>分类</span>
    </router-link>
    <router-link active-class="active" :to="{name: 'm-cart'}">
      <i></i>
      <span>购物车</span>
    </router-link>
    <router-link active-class="active" :to="{name: 'm-mine'}">
      <i></i>
      <span>我的</span>
    </router-link>
  </footer>
</template>

<script>
export default {
  name: "TabBar"
}
</script>

<style scoped lang="scss">
footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  box-shadow: 0 -1px 10px #000;

  /*
  router-link-exact-active
  router-link-active

  /
  /b/a
  /b/c
  */

  a {
    width: 25%;
    text-align: center;
    text-decoration: none;
    padding-top: 7px;

    i {
      display: block;
      height: 30px;
      width: 30px;
      margin: 0 auto;
      background: center / contain;
    }

    &:nth-child(1) i {
      background-image: url("../../assets/images/tab-bar/home.svg");
    }
    &:nth-child(2) i {
      background-image: url("../../assets/images/tab-bar/type.svg");
    }
    &:nth-child(3) i {
      background-image: url("../../assets/images/tab-bar/cart.svg");
    }
    &:nth-child(4) i {
      background-image: url("../../assets/images/tab-bar/mine.svg");
    }

    &.active:nth-child(1) i {
      background-image: url("../../assets/images/tab-bar/home-active.svg");
    }
    &.active:nth-child(2) i {
      background-image: url("../../assets/images/tab-bar/type-active.svg");
    }
    &.active:nth-child(3) i {
      background-image: url("../../assets/images/tab-bar/cart-active.svg");
    }
    &.active:nth-child(4) i {
      background-image: url("../../assets/images/tab-bar/mine-active.svg");
    }

    span {
      display: block;
      font-size: 12px;
    }
  }
}
</style>